/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import model.pojo.Congty;
import model.util.HibernateUtil;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author CUCAINHO
 */
public class CongTyDAO {
    public static Congty LayCongTy(int maCongTy) { 
            
    Congty congTy = null;
    
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
           String hql = "from Congty ct where ct.maCongTy=:maCongTy"; 
            Query query = session.createQuery(hql);
            query.setString("maCongTy", Integer.toString(maCongTy)); 
            congTy = (Congty) query.list().get(0);
            
        }catch (HibernateException ex) 
        { //Log the exception 
            System.err.println(ex); 
        } 
        finally {
            session.close(); 
        } 
    return congTy; 
    }
}
